<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            display: none;
            background-color: pink;
            font-size: 20px;
        }
        input {
            font-size: 16px;
        }
    </style>
</head>
<body>
    <div></div>
    <input type="text">
    <script>
        var inp = document.querySelector('input')
        var div = document.querySelector('div')
        inp.addEventListener('keyup', function(e){
            if (this.value == '') {
                div.style.display = 'none'
            } else {
                div.style.display = 'block'
                div.innerHTML=inp.value
            }
        })
        inp.addEventListener('blur',function(){
            div.style.display= 'none'
        })
        inp.addEventListener('focus',function(){
            if (this.value !== '') {
                div.style.display= 'block'

            }
        })
        
    </script>
</body>
</html>